import request from '@/utils/request'

// 分页
export function pagingPurchaseOrderGoods(query) {
  return request({
    url: '/warehouse/purchaseOrderGoods/paging',
    method: 'get',
    params: query
  })
}

// 根据商品条码获取仓库商品列表
export function getByBarCode(warehouseId, supplierId, goodsBarCode) {
  return request({
    url: '/warehouse/purchaseOrderGoods/getByBarCode',
    method: 'get',
    params: { warehouseId, supplierId, goodsBarCode }
  })
}

// 保存
export function savePurchaseOrderGoods(data) {
  return request({
    url: '/warehouse/purchaseOrderGoods/save',
    method: 'post',
    data: data
  })
}

// 新增或更新采购商品数量
export function savePurchaseNum(data) {
  return request({
    url: '/warehouse/purchaseOrderGoods/savePurchaseNum',
    method: 'post',
    data: data
  })
}

// 重置商品价格
export function doRestPrice(data) {
  return request({
    url: '/warehouse/purchaseOrderGoods/doRestPrice',
    method: 'post',
    data: data
  })
}

// 新增或更新采购商品数量
export function doImportGoods(purchaseOrderId, fileUrl) {
  return request({
    url: '/warehouse/purchaseOrderGoods/doImport',
    method: 'post',
    data: { purchaseOrderId, fileUrl }
  })
}

// 删除
export function deletePurchaseOrderGoods(data) {
  return request({
    url: '/warehouse/purchaseOrderGoods/delete',
    method: 'post',
    data: data
  })
}

// 根据商品条码获取商品可退货数量
export function getNotStockOutNumByBarCode(warehouseId, supplierId, goodsBarCode, relationPurchaseOrderNo) {
  return request({
    url: '/warehouse/purchaseOrderGoods/getNotStockOutNumByBarCode',
    method: 'get',
    params: { warehouseId, supplierId, goodsBarCode, relationPurchaseOrderNo }
  })
}

// 退货单获取关联采购单所有商品
export function pagingPurchaseOrderAllGoods(query) {
  return request({
    url: '/warehouse/purchaseOrderGoods/pagingPurchaseOrderAllGoods',
    method: 'get',
    params: query
  })
}
